package cn.fzkj.lifecircle02;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.PoisonPill;
import akka.actor.Props;

/**
 * @ author mr
 * @ description
 * @ since 2024/12/2
 */
public class Main02 {


    public static void main(String[] args) {
        ActorSystem actorSystem = ActorSystem.create("system-actor");

        ActorRef myWork = actorSystem.actorOf(Props.create(MyWork.class), "MyWork");
        ActorRef watchActor = actorSystem.actorOf(Props.create(WatchActor.class, myWork), "WatchActor");

        myWork.tell(MyWork.Msg.WORKING, ActorRef.noSender());
        myWork.tell(MyWork.Msg.DONE, ActorRef.noSender());

        //中断myWork
        myWork.tell(PoisonPill.getInstance(), ActorRef.noSender());
    }
}
